package com.ibczy.cn.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.xm9m.ibczy.dsp.AdvertFactory;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button obtAddViewA, obtAddViewB, obtAddViewC;
    private LinearLayout linear;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_main);
        initView();
        initData();

        initListener();
    }

    private void initView() {
        obtAddViewA = (Button) findViewById(R.id.ac_main_obt_addView01);
        obtAddViewB = (Button) findViewById(R.id.ac_main_obt_addView02);
        obtAddViewC = (Button) findViewById(R.id.ac_main_obt_addView03);

        linear = (LinearLayout) findViewById(R.id.ac_main_olin_home);
    }

    private void initData() {
    }

    private void initListener() {
        obtAddViewA.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ac_main_obt_addView01:
                addView1();
                break;
        }
    }

    private void addView1() {
        View view2 = AdvertFactory.getViewant(this);
        linear.addView(view2);
    }
}
